package com.zhu.tool_test.mock.comparison;

import com.linktopa.framework.common.model.response.ResponseResult;
import lombok.extern.slf4j.Slf4j;

/**
 * @program: tool_test
 * @description: mock结果比对器
 * @author: ggBall
 * @create: 2020-12-26 16:48
 **/
@Slf4j
public abstract class ComparisonAbs {

    private ResponseResult responseResult;

    /**
     * 返回 期待值
     * @return 期待值
     */
    public abstract String expectValue();

    /**
     * 返回 实际的比对值
     * @return
     */
    public  String actualValue(){
        return responseResult.getCode() + "";
    }

    /**
     * 返回对比结果
     * @param responseResult 接口返回值
     * @param isShowDetail 是否展示 结果
     * @return
     */
    public Boolean compareAsResponseResult(ResponseResult responseResult,Boolean isShowDetail){
        this.responseResult = responseResult;
        if (null == expectValue()) {
            log.warn("期待值不能 null");
            return false;
        }

        // isShowDetail == true 展示 结果
        if (isShowDetail) {
            responseResult.toString();
        }

        return expectValue().equals(actualValue());
    }

    /**
     * 比对 结果
     * @return 结果是否正确
     */
    public Boolean compareAsResponseResult(ResponseResult responseResult){
        return compareAsResponseResult(responseResult,false);
    }



    public ResponseResult getResponseResult() {
        return responseResult;
    }

    public void setResponseResult(ResponseResult responseResult) {
        this.responseResult = responseResult;
    }
}
